package com.xiaoying.chuguoliuxue;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * describe
 * authors liuyaolin
 * createTime 2017/9/14 9:31
 */

public abstract class MyBaseAdapter extends BaseAdapter {
    private Context mContext;
    public MyBaseAdapter(Context context) {
        mContext=context;

    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(getLayout(),parent,false);
        }
        onInit(convertView,position);
        return convertView;
    }

    protected abstract int getLayout();
    protected abstract void onInit(View convertView,int position);
}
